/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sistema.ecua911.datos.BDs;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 *
 * @author pablo
 */
public class OperacionesBase {
     DataBaseManager db = new DataBaseManager();

    public OperacionesBase() {
    }

    public boolean ingreso(String query) throws SQLException {
        Connection var = db.AbrirConexion();
        boolean resultado=true;
        PreparedStatement ps = var.prepareStatement(query);
        ps.execute();
        var.commit();
        ps.close();
        return resultado;
    }

    public ResultSet seleccion(String query) throws SQLException {
        Connection var = db.AbrirConexion();
        Statement stmt = var.createStatement();
        ResultSet resultado = stmt.executeQuery(query);
        return resultado;
    }

    public int modificacioneliminacion(String query) throws SQLException {
        Connection var = db.AbrirConexion();
        Statement stmt = var.createStatement();
        int resultado = stmt.executeUpdate(query);
        var.commit();
        return resultado;
    }
    public void cerrarConexion() throws SQLException {
        db.AbrirConexion().close();
    }
}
